{template 'header'}
<ul class="nav nav-tabs">
    <li class=""><a href="{php echo $this->createWeburl('advertisement');}">广告管理</a></li>
    <li class="active"><a href="{php echo $this->createWeburl('advertisement', array('op' => 'addShow'));}">添加广告</a></li>
</ul>
<form action="" method="post" class="form-horizontal" id="myform" role="form" enctype="multipart/form-data">
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">标题<span style="color: red">*</span>:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="title" placeholder="标题" value="{$advertisement['title']}" type="text">
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">位置</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="position" value="1" {if $advertisement['position'] ==1 || $advertisement['position'] == ''} checked {/if} /> 首页上方
            </label>
            <label class="radio-inline">
                <input type="radio" name="position" value="2" {if $advertisement['position'] ==2} checked {/if}/>首页中间
            </label>
            <label class="radio-inline">
                <input type="radio" name="position" value="3" {if $advertisement['position'] ==3} checked {/if}/>积分商城页
            </label>
        </div>

    </div>
    <div class="form-group" id="ling-1">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">图片:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            {php echo tpl_form_field_image('image',  $advertisement['image'],  tomedia($advertisement['image']));}
            <small style="color: red">首页上方 50 * 50  首页中间 330 * 150  积分商城页  360 * 110</small>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">类型</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="type" value="1" {if $advertisement['type'] ==1 || $advertisement['type'] == ''} checked {/if} /> 当前小程序
            </label>
            <label class="radio-inline">
                <input type="radio" name="type" value="2" {if $advertisement['type'] ==2} checked {/if}/>其他小程序
            </label>
            <label class="radio-inline">
                <input type="radio" name="type" value="3" {if $advertisement['type'] ==3} checked {/if}/>H5
            </label>
            <label class="radio-inline" id="banner"  {if in_array($advertisement['position'], 1,3, '')} style="display: none" {/if}>
                <input type="radio" name="type" value="4" {if $advertisement['type'] ==4} checked {/if}/>流量主/已改为原生广告id
            </label>
        </div>
    </div>
    <div class="form-group" id="appId" {if in_array($advertisement['type'] , array(1, 3, 4,''))} style="display: none" {/if}>
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">appId:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="appid" placeholder="appId" value="{$advertisement['appid']}" type="text">
        </div>
    </div>
    <div class="form-group" id="url" {if $advertisement['type'] == 4} style="display: none" {/if} >
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">地址:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="url" placeholder="小程序地址" value="{$advertisement['url']}" type="text">
        </div>
    </div>
    <div class="form-group" id="flowId" {if $advertisement['type'] != 4} style="display: none" {/if}>
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">流量主:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="group_id" placeholder="流量主" value="{$advertisement['group_id']}" type="text">
        </div>
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">序号:</label>
        <div class="col-sm-7 col-lg-8 col-md-8 col-xs-12">
            <input class="form-control" name="sort" placeholder="序号" value="{$advertisement['sort']}" type="text">
        </div>
    </div>

<!--    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label">是否显示</label>
        <div class="col-sm-9 col-xs-12">
            <label class="radio-inline">
                <input type="radio" name="status" value="1" {if $advertisement['status'] ==1 || $advertisement['status'] == ''} checked {/if} /> 显示
            </label>
            <label class="radio-inline">
                <input type="radio" name="status" value="2" {if $advertisement['status'] ==2} checked {/if}/>隐藏
            </label>

        </div>
    </div>-->

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-1 control-label"></label>
        <div class="" >
            <input type="hidden" name="op" value="{php echo $id ? 'edit' : 'add'}">
            <input type="hidden" name="id" value="{$id}">
            <input type="submit" name="submit" id="submit" value="{php echo $id ? '修改' : '新增'}" class="btn btn-primary">
        </div>
    </div>
</form>
{template 'footer'}


<script>
    $(function () {
        $("input[name='type']").click(function () {
            if ( $(this).val() ==1 || $(this).val() == 3) {
                $('#appId').hide();
                $('#url').show();
                $('#flowId').hide();
            } else if ($(this).val() == 4 ) {
                $('#appId').hide();
                $('#url').hide();
                $('#flowId').show();
            } else {
                $('#appId').show();
            }
        });

        $("input[name='position']").click(function () {

            if ( $(this).val() ==1 || $(this).val() == '') {
                $('#banner').hide();
            } else {
                $('#banner').show();
            }

        });

    })


</script>